this._vpnRequests = { };
this._notifications = { };
- this._pluginDir = Gio.file_new_for_path(Config.VPNDIR);
- try {
- let monitor = this._pluginDir.monitor(Gio.FileMonitorFlags.NONE, null);
- monitor.connect('changed', () => (this._vpnCacheBuilt = false));
- } catch (e) {
- log('Failed to create monitor for VPN plugin dir: %s'.format(e.message));
- }
-
this._native.connect('new-request', this._newRequest.bind(this));
this._native.connect('cancel-request', this._cancelRequest.bind(this));
let vpnSetting = connection.get_setting_vpn();
let serviceType = vpnSetting.service_type;
- this._buildVPNServiceCache();
-
- let binary = this._vpnBinaries[serviceType];
+ let binary = this._findAuthBinary(serviceType);
if (!binary) {
log('Invalid VPN service type (cannot find authentication binary)');
this._vpnRequests[requestId] = vpnRequest;
}
- _buildVPNServiceCache() {
- if (this._vpnCacheBuilt)
- return;
-
- this._vpnCacheBuilt = true;
- this._vpnBinaries = { };
+ _findAuthBinary(serviceType) {
+ const plugin = NM.VpnPluginInfo.new_search_file(null, serviceType);
- NM.VpnPluginInfo.list_load().forEach(plugin => {
- let service = plugin.get_service();
- let fileName = plugin.get_auth_dialog();
- let supportsHints = plugin.supports_hints();
- let externalUIMode = false;
+ if (plugin === null)
+ return null;
- let prop = plugin.lookup_property('GNOME', 'supports-external-ui-mode');
- if (prop) {
- prop = prop.trim().toLowerCase();
- externalUIMode = ['true', 'yes', 'on', '1'].includes(prop);
- }
+ const fileName = plugin.get_auth_dialog();
+ if (!GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
+ log('VPN plugin at %s is not executable'.format(fileName));
+ return null;
+ }
- if (GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
- let binary = { fileName, externalUIMode, supportsHints };
- this._vpnBinaries[service] = binary;
+ const prop = plugin.lookup_property('GNOME', 'supports-external-ui-mode');
+ const trimmedProp = prop ? prop.trim().toLowerCase() : '';
- plugin.get_aliases().forEach(alias => {
- this._vpnBinaries[alias] = binary;
- });
- } else {
- log('VPN plugin at %s is not executable'.format(fileName));
- }
- });
+ return {
+ fileName,
+ supportsHints: plugin.supports_hints(),
+ externalUIMode: ['true', 'yes', 'on', '1'].includes(trimmedProp),
+ };
}
};
var Component = NetworkAgent;